//------------Sonic CD Amy 1 Script-------------//
//--------Scripted by Christian Whitehead 'The Taxman'--------//
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//

//-------Aliases-------//
#alias 54: TYPE_AMY1


sub ObjectMain
	if Object.State==1
		Object.YPos+=Object.Value2
		Object.Value2+=8192
		ObjectTileCollision(0,0,19,0)
		if CheckResult==1
			ResetObjectEntity(Object.EntityNo,TypeName[Amy2],0,Object.XPos,Object.YPos)
			Object.Frame=4
			Object.DrawOrder=4
			Object.Value3=1050935296
			Object.Value4=1073741824
			SaveRAM[343]=1
			if Options.GameMode==1
				WriteSaveRAM()
			endif
		endif
	endif
endsub


sub ObjectPlayerInteraction
	if Object.State==0
#platform: Mobile
		if Object.Type==TypeName[Amy1]
#endplatform
			PlayerObjectCollision(C_TOUCH,-8,-16,8,16)
			if CheckResult==1
				FlipSign(Player.YVelocity)
				Player.YVelocity>>=1
				Object.State=1
				Object.Frame>>=3
				CreateTempObject(TypeName[Explosion],0,Object.XPos,Object.YPos)
				Stage.TimeEnabled=0
				PlaySfx(22,0)
				switch SaveRAM[343]
					case 1
						if Object[24].PropertyValue==2
							SetMusicTrack("JP/R7C.ogg",0,1)
						endif
						if	SaveRAM[341]!=2
							CreateTempObject(TypeName[FadeMusic],1,Object.XPos,Object.YPos)
						endif
					break
				endswitch
#platform: Mobile
		endif
#endplatform
	endif
endsub


sub ObjectDraw
	if Object.State==0
		TempValue0=Object.Frame
		TempValue0>>=3
		DrawSprite(TempValue0)
		Object.Frame++
		Object.Frame&=31
	else
		DrawSprite(Object.Frame)
	endif
endsub


sub ObjectStartup
	LoadSpriteSheet("R7/Objects2.gif")
	ArrayPos0=32
	while ArrayPos0<1056
		if Object[ArrayPos0].Type==TypeName[Amy1]
			if Stage.PlayerListPos==0
				if Options.GameMode==2
					Object[ArrayPos0].Type=TypeName[BlankObject]
				else
					Object[ArrayPos0].DrawOrder=4
				endif
			else
				Object[ArrayPos0].Type=TypeName[BlankObject]
			endif
		endif
		ArrayPos0++
	loop
	SpriteFrame(-12,-20,24,40,1,170)
	SpriteFrame(-12,-20,24,40,1,211)
	SpriteFrame(-12,-20,24,40,124,109)
	SpriteFrame(-12,-20,24,40,1,211)
endsub

sub RSDK
	LoadSpriteSheet("Global/Display.gif")
	SetEditorIcon(Icon0,SingleIcon,-16,-16,32,32,1,143)
endsub
